<script setup lang="ts">
import { RouterView, useRoute } from 'vue-router';
import { onMounted, computed } from 'vue';
import { useUserStore } from './stores/counter';
import TabBar from './components/TabBar.vue';
import FloatingAIChat from './components/FloatingAIChat.vue';

const userStore = useUserStore();
const route = useRoute();

// 判断是否显示底部导航栏
const showNavigation = computed(() => {
  // 登录页面不显示底部导航栏
  return route.path !== '/';
});

// 判断是否显示悬浮按钮（只在首页显示）
const showFloatingChat = computed(() => {
  return route.path === '/home';
});

onMounted(() => {
  // 应用启动时加载用户信息
  userStore.loadUserInfo();
});
</script>

<template>
  <div class="app-container">
    <div class="main-content" :class="{ 'no-padding': !showNavigation }">
      <RouterView />
    </div>
    <TabBar v-if="showNavigation" />
    <FloatingAIChat v-if="showFloatingChat" />
  </div>
</template>

<style>
:root {
  --van-nav-bar-height: 46px;
}

body {
  margin: 0;
  padding: 0;
  background-color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#app {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  min-height: 100vh;
}
</style>

<style scoped>
.app-container {
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  background-color: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  overflow: hidden;
  padding-bottom: 50px;
  /* 为底部导航栏留出空间 */
}

.main-content.no-padding {
  padding-bottom: 0;
}
</style>
